var express = require('express');
var router = express.Router();

const moviesList = [
  {
    id: "1",
    movieName: "朗朗人生",
  },
  {
    id: "2",
    movieName: "志愿者"
  },
  {
    id: "3",
    movieName: "刺杀小说家"
  }
]

router.get('/info', function(req, res, next) {
  // console.log(req.query);
  const {id} = req.query;
  
  if (id) {
    const result = moviesList.filter(item => {
      return item.id === id
    })
    res.json({
      success: true,
      data: result
    })
  } else {
    res.json({
      success: false,
      msg: "参数缺失"
    })
  }
  
});

module.exports = router;
